package spring.cloud.tasks.api.service;

import org.apache.curator.framework.CuratorFramework;
import spring.cloud.tasks.api.domain.zooKeeperClusterAndNameSpace.NameSpace;
import spring.cloud.tasks.api.domain.zooKeeperClusterAndNameSpace.NameSpaceConfiguration;
import spring.cloud.tasks.api.domain.zooKeeperClusterAndNameSpace.NameSpaceZooKeeperClient;
import spring.cloud.tasks.api.domain.zooKeeperClusterAndNameSpace.ZooKeeperCluster;
import spring.cloud.tasks.common.zookeeper.ZooKeeper;

import java.util.List;

public interface ZooKeeperClusterService {


    NameSpaceConfiguration getNameSpaceConfiguration(String nameSpace);

    List<NameSpaceConfiguration> getNameSpaceConfigurationList(ZooKeeperCluster zooKeeperCluster);


    ZooKeeperCluster getZooKeeperCluster(String zooKeeperClusterKey);

    void addZooKeeperCluster(String zooKeeperClusterKey, String connectString, String digest, String description) throws RuntimeException;

    void updateZooKeeperCluster(String zooKeeperClusterKey, String connectString, String description) throws RuntimeException;

    List<ZooKeeperCluster> getZooKeeperClusterList();

    List<ZooKeeperCluster> getOnlineZooKeeperClusterList();

    int nameSpaceCount(String zooKeeperClusterKey);

    boolean nameSpaceCheck(CuratorFramework curatorFramework, String nameSpace) throws RuntimeException;

    List<String> getOnlineNameSpaceList() throws RuntimeException;


    /**
     * Create nameSpace.
     */
    void createNameSpace(NameSpace nameSpace, String userId) throws RuntimeException;


    void deleteNameSpace(String nameSpace) throws RuntimeException;

    /**
     * Get nameSpace by key.
     */
    NameSpace getNameSpace(String nameSpace) throws RuntimeException;


    NameSpaceZooKeeperClient getNameSpaceZooKeeperClient(String nameSpace);

    ZooKeeper connectZooKeeper(String nameSpace) throws RuntimeException;

    ZooKeeper connectZooKeeper(String connectString, String nameSpace) throws RuntimeException;

    void notifyRegistryCenterRefresh() throws RuntimeException;

    void deleteZooKeeperCluster(String zooKeeperClusterKey) throws RuntimeException;
}
